# -*- coding: utf-8 -*-
import random
import os
import signal
import sys

languageDict={"china":[0x4e00,0x09fbf],
              "japanese":[0x3040,0x31ff],
              "korean":[0xac00,0x318f],
              "emoji":[0xe001,0xe05a],       #windows 不支持emoji
              #常用中文字符
              "stockChinese":[19968, 19971, 19975, 19977, 19978, 19979, 19981, 19988, 19990, 19994, 19996, 20004, 20010, 20013, 20026, 20027, 20040, 20041, 20043, 20061, 20063, 20064, 20065, 20070, 20102, 20105, 20107, 20108, 20110, 20116, 20123, 20135, 20142, 20146, 20154, 20160, 20170, 20174, 20182, 20195, 20196, 20197, 20204, 20214, 20219, 20247, 20250, 20255, 20256, 20284, 20294, 20301, 20303, 20307, 20309, 20316, 20320, 20351, 20415, 20449, 20498, 20505, 20570, 20572, 20687, 20799, 20808, 20809, 20837, 20840, 20843, 20844, 20845, 20849, 20851, 20852, 20854, 20869, 20877, 20889, 20891, 20892, 20914, 20915, 20934, 20960, 20986, 20998, 20999, 21018, 21033, 21035, 21040, 21051, 21069, 21147, 21150, 21152, 21160, 21171, 21253, 21270, 21271, 21306, 21313, 21315, 21322, 21335, 21364, 21382, 21387, 21407, 21435, 21448, 21451, 21453, 21457, 21460, 21462, 21463, 21464, 21475, 21476, 21477, 21482, 21483, 21487, 21490, 21494, 21507, 21508, 21512, 21516, 21517, 21518, 21521, 21527, 21543, 21548, 21568, 21578, 21592, 21602, 21628, 21629, 21644, 21681, 21709, 21733, 21738, 21809, 21834, 21862, 22068, 22235, 22238, 22240, 22242, 22260, 22269, 22303, 22312, 22320, 22330, 22352, 22359, 22362, 22478, 22763, 22768, 22788, 22806, 22810, 22812, 22815, 22823, 22825, 22826, 22836, 22899, 22905, 22909, 22914, 23376, 23383, 23398, 23401, 23427, 23436, 23450, 23454, 23478, 23545, 23548, 23558, 23567, 23569, 23601, 23627, 23637, 23665, 23681, 23736, 24037, 24049, 24050, 24072, 24102, 24109, 24110, 24120, 24178, 24179, 24180, 24182, 24212, 24213, 24230, 24231, 24314, 24320, 24351, 24352, 24378, 24403, 24418, 24448, 24456, 24471, 24515, 24517, 24535, 24537, 24555, 24573, 24590, 24597, 24605, 24613, 24615, 24635, 24687, 24744, 24773, 24819, 24847, 24863, 24930, 25104, 25105, 25110, 25112, 25151, 25152, 25163, 25165, 25171, 25214, 25226, 25253, 25289, 25343, 25351, 25481, 25509, 25552, 25910, 25913, 25918, 25919, 25932, 25945, 25954, 25968, 25972, 25991, 26007, 26032, 26041, 26049, 26080, 26085, 26087, 26089, 26102, 26126, 26143, 26159, 26202, 26356, 26368, 26376, 26377, 26381, 26395, 26410, 26412, 26415, 26426, 26449, 26465, 26469, 26497, 26519, 26524, 26538, 26641, 26679, 26681, 27425, 27468, 27492, 27493, 27599, 27604, 27665, 27668, 27700, 27801, 27809, 27827, 27835, 27861, 27963, 27969, 28023, 28145, 28165, 28176, 28385, 28779, 28857, 28909, 28982, 29031, 29228, 29233, 29255, 29275, 29289, 29305, 29616, 29702, 29983, 29992, 30001, 30011, 30028, 30333, 30334, 30340, 30452, 30456, 30475, 30495, 30524, 30528, 30555, 30561, 30693, 30707, 30740, 30772, 30830, 31038, 31070, 31163, 31181, 31185, 31350, 31354, 31359, 31435, 31449, 31456, 31505, 31532, 31561, 31572, 31639, 31867, 31995, 32039, 32423, 32447, 32454, 32463, 32467, 32473, 32676, 32769, 32773, 32780, 32972, 32988, 33050, 33080, 33258, 33267, 33324, 33337, 33394, 33457, 33510, 33609, 33756, 33853, 34892, 34915, 34920, 34987, 35013, 35201, 35265, 35266, 35273, 35299, 35748, 35753, 35760, 35762, 35768, 35770, 35782, 35805, 35813, 35828, 35835, 35841, 36208, 36214, 36215, 36234, 36305, 36319, 36335, 36339, 36523, 36710, 36716, 36731, 36793, 36807, 36816, 36817, 36824, 36825, 36827, 36830, 36865, 36890, 36896, 36947, 37027, 37096, 37117, 37324, 37325, 37326, 37327, 38065, 38271, 38376, 38382, 38431, 38451, 38453, 38454, 38469, 38590, 38632, 38634, 38738, 38750, 38754, 38761, 38899, 39030, 39046, 39064, 39118, 39134, 39277, 39532, 39564, 39640, 40657]
              }

def unicoed(language="china"):
    if len(languageDict[language])>2:
        index=random.randint(0,len(languageDict[language])-1)
        val=languageDict[language][index]
    else:
        val = random.randint(languageDict[language][0], languageDict[language][1])
    return chr(val)

def make_character(length,s='',Type="china"):
    if Type=="emoji":
        length*=10
    for i in range(0,length):
        s=s+unicoed(language=Type)
    return s

#参数 length 字符串长度
#    s 字符串  字符串开头
#    offset 偏置值设置为 65或97 输出为字母
def make_ascii(length,s='',offset=0):
    i=0
    if offset==97 or offset==65:
        i=offset
        while True:
            if i>=offset+26:
                i=offset
            if len(s)==length:
                return s
            s=s+chr(i)
            i+=1
    while True:
        if len(s)>=length:
            return s[:length]
        s=s+str(i)
        i+=1

#参数 length 字符串长度
#    s 字符串  字符串开头
#    Type 默认数字类型 支持类型参考languageDict
def make_str(length,s='',Type="num"):
    s=''
    if Type=="num":
        return make_ascii(length,s)
    elif Type=="english":
        return make_ascii(length,s,97)
    else:
        return make_character(length,s,Type)

if __name__ == "__main__":
    Type={0:'num',1:"english",2:"stockChinese"}
    s=''
    print('输入quit退出\n输入clear请空屏幕')
    while True:
        try:
            length=input(">")
            if length == 'quit':
                break
            elif length =='clear':
                os.system("clear")
                continue
            length = int(length)
        except:
            print("请输入数字")
            continue
        os.system("clear")
        print("")
        typelen=len(Type)
        for i in range(typelen):
            s=make_str(length,s,Type[i])
            print(s)